package com.example.bzh.gamecat.ui.message.publish;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.bzh.gamecat.R;
import com.example.bzh.gamecat.base.BaseActivity;

import butterknife.BindView;
import butterknife.OnClick;

public class PublishActivity extends BaseActivity {

    @BindView(R.id.et_publish_input)
    EditText etPublishInput;
    @BindView(R.id.tv_publish_count)
    TextView tvPublishCount;
    @BindView(R.id.iv_publish_photo1)
    ImageView ivPublishPhoto1;
    @BindView(R.id.iv_publish_photo2)
    ImageView ivPublishPhoto2;
    @BindView(R.id.iv_publish_photo3)
    ImageView ivPublishPhoto3;
    @BindView(R.id.iv_publish_addphoto)
    ImageView ivPublishAddphoto;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_publish;
    }

    @Override
    public void initData() {
        super.initData();
        etPublishInput.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int start, int after, int count) {
                String s = etPublishInput.getText().toString();
                if (after >= 200) {
                    tvPublishCount.setText("200");
                } else {
                    tvPublishCount.setText(s.length() + "");
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }

    @OnClick({R.id.iv_publish_back, R.id.tv_publish_publish, R.id.iv_publish_addphoto})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_publish_back:
                finish();
                break;
            case R.id.tv_publish_publish:
                // TODO: 2016/8/13 将动态发表
                break;
            case R.id.iv_publish_addphoto:
                // TODO: 2016/8/13 添加图片，最多3张
                break;
        }
    }
}
